﻿using System;
using System.Collections.Generic;
using System.Reflection;
using Abp.Modules;

namespace SNX.TestTool.Modules
{
    public abstract class TestModule : AbpModule
    {
        public string ModuleName { get; protected set; }

        public string Description { get; protected set; }

        public List<ModuleParameterDefinition> ParameterDefinitionItems { get; } = new List<ModuleParameterDefinition>();

        public List<BaseTestCase> TestItems { get; } = new List<BaseTestCase>();

        /// <summary>
        /// Checks if given type is an Test module class.
        /// </summary>
        /// <param name="type">Type to check</param>
        /// <returns>type is an Test module</returns>
        public static bool IsTestModule(Type type)
        {
            var typeInfo = type.GetTypeInfo();
            return
                typeInfo.IsClass &&
                !typeInfo.IsAbstract &&
                !typeInfo.IsGenericType &&
                typeof(TestModule).IsAssignableFrom(type);
        }

        public void AddParameter(ModuleParameterDefinition parameterDefinition)
        {
            this.ParameterDefinitionItems.Add(parameterDefinition);
        }
    }
}
